//
//  WYMyRedPacketController.m
//  Boss
//
//  Created by admin on 2018/6/7.
//  Copyright © 2018年 admin. All rights .
//

#import "WYMyRedPacketController.h"
#import "SGPagingView.h"
#import "WYReceivedController.h"
#import "WYSendOutController.h"
@interface WYMyRedPacketController ()<SGPageTitleViewDelegate,SGPageContentScrollViewDelegate>
@property (nonatomic, strong) SGPageTitleView *pageTitleView;
@property (nonatomic, strong) SGPageContentScrollView *pageContentView;
@end

@implementation WYMyRedPacketController
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = NO;
}
-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
}
-(void)setupUI
{
    [self wr_setNavBarShadowImageHidden:YES];
    CGFloat top = 64;
    if (kDevice_Is_iPhoneX) {
        top = 88;
    }
    
    NSArray *titleArr = @[@"收到的红包", @"我发的红包"];
    
     SGPageTitleViewConfigure *configure = [SGPageTitleViewConfigure pageTitleViewConfigure];
    configure.titleColor = [UIColor hexStringToColor:@"#f7ddd8" alpha:1.0];
    configure.titleSelectedColor = [UIColor hexStringToColor:@"#ffffff" alpha:1.0];
    configure.showIndicator = NO;
    
    self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, top, self.view.frame.size.width, 44) delegate:self titleNames:titleArr configure:configure];
    [self.view addSubview:_pageTitleView];
    self.pageTitleView.backgroundColor = kColorMainColor;
//    self.pageTitleView.titleColorStateNormal = [UIColor hexStringToColor:@"#f7ddd8" alpha:1.0];
//    self.pageTitleView.titleColorStateSelected = [UIColor hexStringToColor:@"#ffffff" alpha:1.0];
//    self.pageTitleView.isShowIndicator = NO;
    
    
    
    WYReceivedController *oneVC = [[WYReceivedController alloc]init];
    
    WYSendOutController *twoVC = [[WYSendOutController alloc]init];
    
    NSArray *childVCArr = @[oneVC, twoVC];
    CGFloat contentViewHeight = kScreenHeight - 44-top;
    self.pageContentView = [[SGPageContentScrollView alloc] initWithFrame:CGRectMake(0, 44+top, self.view.frame.size.width, contentViewHeight) parentVC:self childVCs:childVCArr];
    _pageContentView.delegatePageContentScrollView = self;
    [self.view addSubview:_pageContentView];
    self.navigationItem.title = @"我的红包";
    
}
//- (void)pageContentView:(SGPageContentView *)pageContentView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex {
//    [self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
//}
- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex {
    [self.pageContentView setPageContentScrollViewCurrentIndex:selectedIndex];
}
- (void)pageContentScrollView:(SGPageContentScrollView *)pageContentScrollView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex
{
    [self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
}
//- (void)SGPageTitleView:(SGPageTitleView *)SGPageTitleView selectedIndex:(NSInteger)selectedIndex
//{
//    [self.pageContentView setPageContentScrollViewCurrentIndex:selectedIndex];
//}
@end
